{% set pypi_name = 'vmware-nsxlib' %}
{% set source = fetch_source('https://tarballs.openstack.org/vmware-nsxlib/vmware-nsxlib-master.tar.gz') %}
{% set upstream_version = upstream_version() %}
{% set rpm_release = '1' %}
# FIXME(jpena): oslosphinx does not work with sphinx > 2
# Set this variable to 1 when that is fixed
%global with_doc 0
Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        VMware NSX python library
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/vmware-nsxlib
Source0:        {{ source|basename }}
BuildRequires:  fdupes
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('decorator') }}
BuildRequires:  {{ py3('eventlet') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('neutron-lib') }}
BuildRequires:  {{ py3('oslo.log') }}
BuildRequires:  {{ py3('oslo.service') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('pyOpenSSL') }}
BuildRequires:  {{ py3('requests-mock') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('tenacity') }}
BuildRequires:  {{ py3('testrepository') }}
BuildRequires:  {{ py3('testresources') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
vmware-nsxlib is a python library that interfaces with VMWare NSX

%package -n python3-vmware-nsxlib
Summary:        VMware NSX python library
Requires:       {{ py3('decorator') }}
Requires:       {{ py3('eventlet') }}
Requires:       {{ py3('netaddr') }}
Requires:       {{ py3('neutron-lib') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('oslo.log') }}
Requires:       {{ py3('oslo.serialization') }}
Requires:       {{ py3('oslo.service') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('pyOpenSSL') }}
Requires:       {{ py3('six') }}
Requires:       {{ py3('tenacity') }}

%description -n python3-vmware-nsxlib
vmware-nsxlib is a python library that interfaces with VMWare NSX

This package contains the Python 3.x module.

%if 0%{?with_doc}
%package -n python-vmware-nsxlib-doc
Summary:        Documentation for vmware-nsxlib
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('oslosphinx') }}

%description -n python-vmware-nsxlib-doc
vmware-nsxlib is a python library that interfaces with VMWare NSX
This package contains the documentation
%endif

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}
%if 0%{?with_doc}
# generate html docs
PBR_VERSION={{ upstream_version }} %sphinx_build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}
%fdupes doc/build/html/
%endif

%install
%{py3_install}
# remove duplicates
%fdupes %{buildroot}%{python3_sitelib}

%check
python3 -m stestr.cli run

%files -n python3-vmware-nsxlib
%license LICENSE
%{python3_sitelib}/vmware_nsxlib
%{python3_sitelib}/*.egg-info

%if 0%{?with_doc}
%files -n python-vmware-nsxlib-doc
%license LICENSE
%doc README.rst doc/build/html
%endif

%changelog
